package lk.service.blogspringboot.config;

import lk.service.blogspringboot.interceptor.MyRequestInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 我的配置类
 * LK  2024/07/13
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    /**
     * 添加拦截器配置
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyRequestInterceptor())
                .addPathPatterns("/**"); // 设置拦截的路径规则，这里表示拦截所有请求，但是不拦截在MyRequestInterceptor忽略的请求
    }
}